<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreatePermissionsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('permissions', function (Blueprint $table) {
            $table->id();
            $table->string('permissionName')->unique()->comment('权限名称');
            $table->string('description')->nullable()->comment('权限描述');
            $table->bigInteger('categoryId')->unsigned();
            $table->string('remark')->nullable()->comment('备注');

            $table->engine = 'InnoDB';
        });
        Schema::table('permissions', function (Blueprint $table) {
            $table->foreign('categoryId')->references('id')->on('dictionary');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('permissions');
    }
}
